import { FILTER_ACTIVE } from '../constants'

export const filterActiveAc = (active) => ({
  type: FILTER_ACTIVE,
  active,
})

// 需求：点击按钮 1s 后再进行切换
export const filterActive = (active) => {
  // 一旦应用 redux-thunk 中间件，这里就支持返回函数
  return (dispatch) => {
    // 函数里面就可以做异步相关的操作啦
    // dispatch => 内置的 dispatch => react-redux
    setTimeout(() => {
      dispatch(filterActiveAc(active))
    }, 1000)
  }
}
